<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
  <head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta name="keywords" content="scclui框架">
	<meta name="description" content="scclui为轻量级的网站后台管理系统模版。">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
    <title>首页</title>
	  <script type="text/javascript" src="/HouTaiGuanLiZuiZhong/recycle/Public/common/js/jquery-1.8.2.min.js"></script>
	  <script type="text/javascript">
		  $(function () {
//			  添加品牌
			  $('#insertBrand').click(function () {
				  var brand = $("input[name='brand']").val();
				  var class_id = $("input[name='class_id']").val();
				  var url = $("#hid").val();
				  $.get(url, {brand: brand, class_id: class_id}, function (data) {
					  if (data) {
						  alert(data)
						  window.location.reload()
					  } else {
						  alert('添加失败');
					  }
				  })
			  })
			  //			  删除品牌
			  $('.delete_brand').click(function(e){
				  e.preventDefault();
				  var url = $('#hid').val();
				  var id = $(this).attr("href");
				  $.get(url,{id:id},function(data){
					  if(data){
						  alert(data)
						  window.location.reload()
					  }else{
						  alert('删除失败')
					  }
				  })
			  })
			  //修改品牌
			$('.update_brand').click(function (e) {
				e.preventDefault();
				var id=$(this).attr('href');
				$('body').append("<p>写下修改的名称:</p><input type='text' name='updateName'><button id='updateBtn'>修改</button>")
				$('#updateBtn').click(function () {
					var url=$("#brandUrl").val();
					var updateName=$("input[name='updateName']").val();
					$.get(url,{id:id,updateName:updateName},function(data){
						if(data){
							alert(data)
							window.location.reload();
						}else{alert("未知错误")}
					})
				})
			})
  })

	  </script>
  </head>
  
  <body>
	<!--品牌管理test2-->
	<b>当前品牌：</b>
	<table>
		<?php if($rs == array()): ?>当前还没有品牌，您可以点击添加品牌
			<?php else: ?>
			<tr>
			<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td style="border:1px solid"><?php echo ($data["brand"]); ?></td><?php endforeach; endif; else: echo "" ;endif; ?>
			</tr><?php endif; ?>
	</table>
	<p><b>添加品牌：</b></p>
	<p>
		输入品牌名：
		<input type="text" name="brand">
		<input type="hidden" id="hid" value="<?php echo U('checkBrand');?>">
	</p>
	<p>
		输入分类名：
		<input type="text" name="class_id">
		<button id="insertBrand">添加</button>
		提示：手机为1；平板电脑为2
	</p>
	<p>
		<b>请点击要删除的品牌：</b>
	<table>
		<tr>
		<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td><a href="<?php echo ($data["id"]); ?>" class="delete_brand"><?php echo ($data["brand"]); ?> </a></td><?php endforeach; endif; else: echo "" ;endif; ?>
		</tr>
	</table>
	</p>
		<b>请点击要修改的品牌名：</b>
	<table>
		<tr>
			<?php if(is_array($rs)): $i = 0; $__LIST__ = $rs;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$data): $mod = ($i % 2 );++$i;?><td><a href="<?php echo ($data["id"]); ?>" class="update_brand" style="text-decoration: none"><?php echo ($data["brand"]); ?> </a></td><?php endforeach; endif; else: echo "" ;endif; ?>
		</tr>
		<input type="hidden" value="<?php echo U('updateBrand');?>" id="brandUrl">
	</table>
  </body>
</html>